package demo;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

//Day08
public class Day18006 {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("王佳乐");
        list.add("张三丰");
        list.add("王思聪");
        list.add("张飞");
        list.add("刘晓敏");
        list.add("张靓颖");
        list.add("王敏");
//        筛选张姓
        Stream<String> streamZhang= list.stream().filter(s -> (s.indexOf("张")!=-1));
//        筛选王姓
        Stream<String> streamWang= list.stream().filter(s -> (s.indexOf("王")!=-1));
//        合并流
        List<String> addList= Stream.concat(streamWang,streamZhang).collect(Collectors.toList());
//        找到名字是三个的
        int i=0;
        for (String s:
             addList) {
            if(s.length()==3){
                i++;
                System.out.println(s);
            }
        }
        System.out.println("名字是三个字的有"+i+"个");
    }
}
